<template>
  <!-- 申请记录 -->
  <div class="app-container">
    <searchForm
      :formOptions="formOptions"
      @onSearch="onSearch"
      @onReset="onReset"
      :formLabelWidth="formLabelWidth"
      v-show="showSearch"
    />

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['clr:apprclrinfo:appr']"
        >申请</el-button>
        <el-button
          type="primary"
          plain
          size="mini"
          @click="adjust"
          v-hasPermi="['clr:apprclrinfo:adjust']"
        >信息调整</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['clr:apprclrinfo:edit']"
        >修改</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['clr:apprclrinfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['clr:apprclrinfo:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="apprclrinfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" type="index"/>
      <el-table-column label="申请人工号" align="center" prop="applyTno"></el-table-column>
      <el-table-column label="申请人名称" align="center" prop="applyName"></el-table-column>
      <el-table-column label="申请时间" sortable align="center" prop="applyTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applyTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="调整类型" align="center" prop="applyRule">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.clr_rule_type" :value="scope.row.applyRule" />
        </template>
      </el-table-column>
      <el-table-column label="审批状态" align="center" prop="apprStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.clr_appr_status" :value="scope.row.apprStatus" />
        </template>
      </el-table-column>
      <el-table-column label="审批记录" align="center" prop="apprStatus">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="viewDetails(scope.row)"
            v-hasPermi="['clr:apprclrinfo:query']"
          >查看审批</el-button>
        </template>
      </el-table-column>
      <!-- <el-table-column label="参数信息" align="center" prop="parameter"></el-table-column>
      <el-table-column label="数据过滤" align="center" prop="deptId"></el-table-column> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="examine(scope.row)"
            v-hasPermi="['clr:apprclrinfo:apprclrinfo']"
            :disabled= "scope.row.apprStatus == '0' ? false: true"
          >审批</el-button>
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['clr:apprclrinfo:edit']"
          >修改</el-button> -->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['clr:apprclrinfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 查看审批 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="60%"
      ppend-to-body
      @close="CloseIn"
      destroy-on-close
    >
      <!-- <el-form ref="form" :model="form" label-width="70px">
        <el-row>
          <el-col :span="10">
            <el-form-item label="教师信息" prop="tno">
              <el-autocomplete
                class="inputInfo"
                v-model="searchcursom"
                :fetch-suggestions="querySearch"
                :trigger-on-focus="false"
                style="width: 100%;"
                placeholder="请输入内容"
                @select="handleSelects"
              >
                <template slot-scope="{ item }">
                  <div class="name">姓名:{{ item.value }},工号:{{ item.address }}</div>
                </template>
              </el-autocomplete>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>-->
      <el-form ref="form" :model="form" v-if="apprData.parameter" :rules="rules" label-width="95px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="所属院系" prop="deptId">
              <el-cascader
                v-model="form.deptId"
                :options="deptOptions"
                :props="{ value: 'id',currentLabels: 'label',checkStrictly: true }"
                style="width: 100%"
                @change="handleChange"
                clearable
                disabled
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="来校日期" prop="admissionTime">
              <el-date-picker
                v-model="form.admissionTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择来校日期"
                style="width: 100%"
                disabled
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工号" prop="tno">
              <el-input v-model.trim="form.tno" clearable placeholder="请输入工号" maxlength="30" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="姓名" prop="name">
              <el-input v-model.trim="form.name" clearable placeholder="请输入姓名" maxlength="10" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="性别" prop="sex">
              <el-select v-model="form.sex" clearable placeholder="请选择性别" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dict.type.sys_user_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="在职状态" prop="postStatus" disabled>
              <el-select
                v-model="form.postStatus"
                clearable
                placeholder="请选择在职状态"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_post_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="血型" prop="bloodType">
              <el-select clearable v-model="form.bloodType" placeholder="请选择血型" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dict.type.basic_blood_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="身份证件号" prop="cardCode" >
              <el-input
                v-model.trim="form.cardCode"
                placeholder="请输入身份证件号"
                clearable
                maxlength="18"
                @blur="codeBulr"
                disabled
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出生日期" prop="birthday">
              <el-date-picker
                v-model="form.birthday"
                disabled
                type="date"
                placeholder="选择出生日期"
                style="width: 100%"
                value-format="yyyy-MM-dd"
                format="yyyy-MM-dd"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系方式" prop="phone">
              <el-input v-model.trim="form.phone" placeholder="请输入联系方式" maxlength="11" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="民族" prop="nation">
              <el-select v-model="form.nation" placeholder="请选择民族" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dict.type.bc_nation_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="政治面貌" prop="political">
              <el-select v-model="form.political" placeholder="请选择政治面貌" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dict.type.bc_political_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="曾用名" prop="formerName">
              <el-input v-model.trim="form.formerName" placeholder="请输入曾用名" maxlength="10" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="籍贯" prop="bnpId">
              <el-cascader v-model="form.bnpId" clearable style="width: 100%;" disabled
                :props="{ value: 'unitCode',currentLabels: 'label' }"
                 :options="options" @change="handlePlace"></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="学历" prop="education">
              <el-select v-model="form.education" placeholder="请选择学历" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dict.type.basic_education_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="学位" prop="acDegree">
              <el-select v-model="form.acDegree" placeholder="请选择学位" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dict.type.basic_degree_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="职称" prop="title">
              <el-select v-model="form.title" placeholder="请选择职称" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dict.type.basic_title_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="职称级别" prop="titleLevel">
              <el-select v-model="form.titleLevel" placeholder="请选择职称级别" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dict.type.basic_title_level"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- 班级选择：<el-badge :value="sendUserIds.length" :hidden="!sendUserIds.length" :type="'primary'">
                <el-button size="small" @click="selectUserBtn">选择</el-button>
              </el-badge> -->
       
             
     
      <h2>工作经历</h2>
      <el-table
        :data="clrWorkHistoryList"
        @selection-change="handleClrWorkHistorySelectionChange"
        ref="clrWorkHistory"
      >
        <el-table-column label="序号" align="center" type="index" width="50" />
        <el-table-column label="公司名称" prop="cName" align="center"></el-table-column>
        <el-table-column label="开始时间" prop="startDate" align="center"></el-table-column>
        <el-table-column label="结束时间" prop="endDate" align="center"></el-table-column>
        <el-table-column label="职位名称" prop="jobTitle" align="center"></el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="workDetails(scope.row)"
            >查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-dialog
        width="50%"
        title="工作经历"
        :visible.sync="innerVisible"
        append-to-body
        destroy-on-close
      >
        <el-form ref="formWork" :model="formWork" :rules="workRules" label-width="90px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="公司名称" prop="cName">
                <el-input v-model="formWork.cName" placeholder="请输入公司名称" maxlength="30" disabled/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="职位名称" prop="jobTitle">
                <el-input v-model="formWork.jobTitle" placeholder="请输入职位名称" maxlength="30" disabled/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="起止时间">
                <el-date-picker
                  v-model="dataTime"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="yyyy-MM-dd"
                  disabled
                ></el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="工作内容" prop="workContent">
                <editor v-model="formWork.workContent" :min-height="180" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="工作业绩" prop="workPerformance">
                <editor v-model="formWork.workPerformance" :min-height="180" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitWork" :disabled="workDisabled">确 定</el-button>
          <el-button @click="innerVisible = false">取 消</el-button>
        </div>
      </el-dialog>
      <h2>教育背景</h2>
      <!-- <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="educationalVisible = true">新增</el-button> -->
      <el-table :data="clrEducationList">
        <el-table-column label="学历" prop="education" align="center" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.basic_education_type" :value="scope.row.education" />
          </template>
        </el-table-column>
        <el-table-column label="毕业学校" prop="sName" :show-overflow-tooltip="true" align="center" />
        <el-table-column label="毕业专业" prop="gMajor" :show-overflow-tooltip="true" align="center" />
        <el-table-column label="学习方式" prop="lStyle" :show-overflow-tooltip="true" align="center">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.clr_learning_style" :value="scope.row.lStyle" />
          </template>
        </el-table-column>
        <el-table-column label="学制" prop="eSystem" :show-overflow-tooltip="true" align="center">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.bc_speciality_type" :value="scope.row.eSystem" />
          </template>
        </el-table-column>
        <el-table-column label="毕业时间" prop="endDate" align="center" :show-overflow-tooltip="true" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="educationDetails(scope.row)"
            >查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <h2>所带班级</h2>
      <el-table
        :data="sendUserIds"
        @selection-change="handleClrWorkHistorySelectionChange"
        ref="clrWorkHistory"
      >
        <el-table-column label="序号" align="center" type="index" width="50" />
        <el-table-column label="所属院系" prop="deptNames" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column label="专业" prop="specialtyName" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column label="入学年级" prop="gradeName" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column label="班号" prop="classCode" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column label="班级名称" prop="className" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column label="班级人数" prop="classSize " align="center" show-overflow-tooltip></el-table-column>
      </el-table>
      <el-dialog
        width="50%"
        title="教育背景"
        :visible.sync="educationalVisible"
        append-to-body
        destroy-on-close
      >
        <el-form
          ref="educationFrom"
          :model="educationFrom"
          :rules="educationRole"
          label-width="90px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item label="学历" prop="education">
                <el-select v-model="educationFrom.education" placeholder="请选择" style="width: 100%" disabled>
                  <el-option
                    v-for="dict in dict.type.basic_education_type"
                    :key="dict.index"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="毕业学校" prop="sName">
                <el-input v-model="educationFrom.sName" placeholder="请输入毕业学校" maxlength="30" disabled/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学校类型" prop="sType">
                <el-select v-model="educationFrom.sType" placeholder="请选择" style="width: 100%" disabled>
                  <el-option
                    v-for="dict in dict.type.clr_school_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="授予国家" prop="educationCountry">
                <el-select
                  v-model="educationFrom.educationCountry"
                  placeholder="请选择"
                  style="width: 100%" disabled
                >
                  <el-option
                    v-for="dict in dict.type.basic_stu_duties"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="入校时间" prop="startDate">
                <el-date-picker
                  v-model="educationFrom.startDate"
                  type="date"
                  value-format="yyyy-MM-dd" disabled
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="毕业时间" prop="endDate">
                <el-date-picker
                  v-model="educationFrom.endDate"
                  type="date" disabled
                  value-format="yyyy-MM-dd"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学科" prop="discipline">
                <el-input v-model="educationFrom.discipline" placeholder="请输入学科" maxlength="30" disabled/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="毕业专业" prop="gMajor">
                <el-input v-model="educationFrom.gMajor" placeholder="请输入毕业专业" maxlength="30" disabled/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学习形式" prop="lModality">
                <el-select v-model="educationFrom.lModality" placeholder="请选择" style="width: 100%" disabled>
                  <el-option
                    v-for="dict in dict.type.clr_learning_forms"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学习方式" prop="lStyle">
                <el-select v-model="educationFrom.lStyle" placeholder="请选择" style="width: 100%" disabled>
                  <el-option
                    v-for="dict in dict.type.clr_learning_style"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学制" prop="eSystem">
                <el-select v-model="educationFrom.eSystem" placeholder="请选择" style="width: 100%" disabled>
                  <el-option
                    v-for="dict in dict.type.bc_speciality_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否最高学历" prop="isEducation">
                <el-select
                  v-model="educationFrom.isEducation"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.sys_yes_no"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位" prop="aDegree">
                <el-input v-model="educationFrom.aDegree" placeholder="请输入学习形式" maxlength="30" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位类型" prop="degreeType">
                <el-select v-model="educationFrom.degreeType" placeholder="请选择" style="width: 100%">
                  <el-option
                    v-for="dict in dict.type.basic_degree_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位授予国家" prop="degreeCountry">
                <el-select
                  v-model="educationFrom.degreeCountry"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.basic_stu_duties"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位授予单位" prop="degreeUnit">
                <el-input
                  v-model="educationFrom.degreeUnit"
                  placeholder="请输入学位授予单位"
                  maxlength="30"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位授予日期" prop="degreeDate">
                <el-date-picker
                  v-model="educationFrom.degreeDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否最高学位" prop="isDegree">
                <el-select v-model="educationFrom.isDegree" placeholder="请选择" style="width: 100%">
                  <el-option
                    v-for="dict in dict.type.sys_yes_no"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位专业" prop="degreeMajor">
                <el-input v-model="educationFrom.degreeMajor" placeholder="请输入学位专业" maxlength="30" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitEducation" :disabled="educationDisabled">确 定</el-button>
          <el-button @click="educationalCancel">取 消</el-button>
        </div>
      </el-dialog>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">通 过</el-button>
        <el-button @click="refuse">拒 绝</el-button>
      </div>
     
    </el-dialog>
    <!-- 查看审批详情 -->
    <el-dialog :title="title" :visible.sync="beginOpen" width="60%" append-to-body>
      <el-table v-loading="loading" :data="clrApprRecordList">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="序号" align="center" type="index"/>
      <el-table-column label="审批角色" align="center" prop="roleName"></el-table-column>
      <el-table-column label="审批人" align="center" prop="apprName"></el-table-column>
      <el-table-column label="审批人工号" align="center" prop="apprTno"></el-table-column>
      <el-table-column label="审批时间" align="center" prop="apprTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.apprTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审批状态" align="center" prop="apprStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.clr_appr_status" :value="scope.row.apprStatus" />
        </template>
      </el-table-column>
    </el-table>

    <!-- <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    /> -->
    </el-dialog>
  </div>
</template>

<script>
import {
  listApprclrinfo,
  getApprclrinfo,
  delApprclrinfo,
  addApprclrinfo,
  updateApprclrinfo,
  appr
} from "@/api/clr/apprclrinfo";
import searchForm from "@/components/Search/searchForm.vue";
import { getDicts } from "@/api/system/dict/type";
import { deptTreeSelect } from "@/api/system/user";
import { getProvinceTree } from "@/api/information/classInfor";

export default {
  name: "Apprclrinfo",
  components: { searchForm },
  dicts: [
    "clr_appr_status",
    'clr_rule_type',
    "basic_education_type", // 学历类型
    "basic_degree_type", // 学位类型
    "sys_user_sex", // 性别
    "bc_political_type", // 政治面貌
    "bc_nation_type", // 民族类型
    "clr_counsellor_type", // 是否辅导员
    "clr_cthr_type", // 是否班主任
    "bc_office_type", // 任职类型
    "basic_post_status", //在岗状态
    "clr_learning_style", //学习方式
    "clr_learning_forms", //学习形式
    "clr_school_type", //学校类型
    "sys_yes_no", //学位类型
    "basic_blood_type", // 血型
    "basic_title_type", // 职称类型
    "basic_title_level", // 职称级别
    "bc_speciality_type" //学制类型
  ],
  data() {
    return {
      // 遮罩层
      loading: true,
      formLabelWidth: "85px",
      formOptions: [
        {
          label: "申请人工号",
          prop: "applyTno",
          element: "el-input",
          placeholder: "请输入申请人工号"
        },
        {
          label: "申请人名称",
          prop: "applyName",
          element: "el-input",
          placeholder: "请输入申请人名称"
        },
        {
          label: "申请时间",
          prop: "applyTime",
          type: "daterange",
          element: "el-date-picker",
          placeholder: "请选择时间"
        },
        {
          label: "审批状态",
          prop: "apprStatus",
          element: "el-select",
          options: [],
          placeholder: "请选择审批状态"
        },
        {
          label: "调整类型",
          prop: "applyRule",
          element: "el-select",
          options: [],
          placeholder: "请选择调整类型"
        },
      ],
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedClrApprRecord: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      names:[], // 删除传递的名字
      // 辅导员信息申请单表格数据
      apprclrinfoList: [],
      // 辅导员审批记录表格数据
      clrApprRecordList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      beginOpen: false,
      deptOptions: [],
      clrEducationList: [], //
      formWork: {},
      clrWorkHistoryList: [],
      educationSname: [],
      dataTime: [],
      innerVisible: false, // 添加工作经历弹窗
      educationalVisible: false, // 教育背景弹窗
      workDisabled: false,
      educationDisabled: false,
      sendUserIds: [],
      dateRange:[],
      options: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        applyTno: null,
        applyName: null,
        applyTime: null,
        applyRule: null,
        apprStatus: null
      },
      // 表单参数
      form: {
        teacher:{}
      },
      apprData: {},
      educationFrom: {},
      // 表单校验
      rules: {},
      workRules: {
        cName: [{ required: true, message: "请输入公司名称", trigger: "bulr" }],
        jobTitle: [
          { required: true, message: "请输入职务名称", trigger: "bulr" }
        ],
        startDate: [
          { required: true, message: "请选择时间", trigger: "change" }
        ],
        endDate: [{ required: true, message: "请选择时间", trigger: "change" }]
      },
      educationRole: {
        education: [
          { required: true, message: "请选择学历", trigger: "change" }
        ],
        sName: [{ required: true, message: "请输入毕业学校", trigger: "bulr" }],
        gMajor: [
          { required: true, message: "请输入毕业专业", trigger: "bulr" }
        ],
        startDate: [
          { required: true, message: "请选择入校时间", trigger: "change" }
        ],
        endDate: [
          { required: true, message: "请选择毕业时间", trigger: "change" }
        ],
        lStyle: [
          { required: true, message: "请选择学习方式", trigger: "change" }
        ],
        eSystem: [{ required: true, message: "请选择学制", trigger: "change" }]
      }
    };
  },
  created() {
    this.getList();
    getDicts("clr_appr_status").then(res => {
      this.formOptions[3].options = res.data.map(item => {
        return {
          value: item["dictValue"],
          label: item["dictLabel"]
        };
      });
    });
    getDicts("clr_rule_type").then(res => {
      this.formOptions[4].options = res.data.map(item => {
        return {
          value: item["dictValue"],
          label: item["dictLabel"]
        };
      });
    });
     // 籍贯下拉书
     getProvinceTree().then(response => {
        this.options = response.data
      
      });

  },
  computed: {
    userInfor() {
      return this.$store.state.user.userInfor;
    }
  },
  methods: {
      // 获取搜索表单提交的数据
      onSearch(val) {
       
        if(val.applyTime){
      this.dateRange = val.applyTime
        }
      this.queryParams = Object.assign((this.queryParams, val));
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置
    onReset(data) {
      console.log(data,'data')
      data.params = {}
      this.dateRange = []
      this.queryParams.pageNum = 1;
      this.queryParams = Object.assign(this.queryParams, data);
      this.getList();
    },
    /** 查询辅导员信息申请单列表 */
    getList() {
      this.loading = true;
      this.queryParams.applyTime = []
      listApprclrinfo(this.addDateRange(this.queryParams,this.dateRange )).then(response => {
        this.apprclrinfoList = response.rows;
        this.queryParams.applyTime = this.dateRange
        this.total = response.total;
        this.loading = false;
      });
    },
    handlePlace(data) {
      // this.form.bnpId = data[data.length - 1]
      this.form.bnpId = data[data.length - 1]
    },
   
    // 修改
    handleUpdate() {},
    // 清除表单
    CloseIn() {
      this.form = {};
      this.formTeacher = {};
      this.open = false;
    },
    handleChange(value) {
      if (value) {
        this.form.deptId = value[value.length - 1];
      }
      // this.form.deptId = value[2];
      // this.form.multistage = value + "";
    },
    // 根据身份证号获取出生年月
    codeBulr() {
      if (this.form.cardCode) {
        this.$set(this.form, "birthday", this.getBirthday(this.form.cardCode));
      }
    },
    // 弹窗取消
    educationalCancel() {
      this.educationalVisible = false;
      this.resetForm("educationFrom");
    },
    // 获取部门信息
    async department() {
      await deptTreeSelect().then(res => {
        this.deptOptions = res.data;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.names = selection.map(item => item.applyName);
      this.ids = selection.map(item => item.caiId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    // 工作经历
    submitWork() {
      console.log(this.dataTime, "submitWork");
      if (this.dataTime.length == 0) {
        this.$modal.msgWarning("请选择时间");
      } else {
        if (this.clrWorkHistoryList.length > 0) {
          this.clrWorkHistoryList.forEach(element => {
            if (element.cName == this.formWork.cName) {
              this.$modal.msgWarning("添加的工作单位已存在");
            } else {
              this.$refs["formWork"].validate(valid => {
                if (valid) {
                  this.clrWorkHistoryList = this.clrWorkHistoryList;
                  this.clrWorkHistoryList.push(this.formWork);
                  this.dataTime = [];
                  this.formWork = {};
                  this.innerVisible = false;
                }
              });
            }
          });
        } else {
          this.$refs["formWork"].validate(valid => {
            if (valid) {
              this.clrWorkHistoryList = this.clrWorkHistoryList;
              this.clrWorkHistoryList.push(this.formWork);
              this.dataTime = [];
              this.formWork = {};
              this.innerVisible = false;
            }
          });
        }
      }
    },
    selectUserBtn() {
      this.$refs.selectUserRef.open();
    },
    // 工作经历多选
    handleClrWorkHistorySelectionChange(selection) {
      this.workCname = selection;
      this.multiple = !selection.length;
    },
    // 教育背景参数添加
    submitEducation() {
      if (this.clrEducationList.length > 0) {
        this.clrEducationList.forEach(element => {
          if (element.sName == this.educationFrom.sName) {
            this.$modal.msgWarning("添加的学校已存在");
          } else {
            this.$refs["educationFrom"].validate(valid => {
              if (valid) {
                this.clrEducationList = this.clrEducationList;
                this.clrEducationList.push(this.educationFrom);
                this.educationalVisible = false;
                this.educationFrom = {};
              } else {
              }
            });
          }
        });
      } else {
        this.$refs["educationFrom"].validate(valid => {
          if (valid) {
            this.clrEducationList = this.clrEducationList;
            console.log(this.educationFrom, "push");
            this.clrEducationList.push(this.educationFrom);
            console.log(this.clrEducationList, "添加");

            this.educationalVisible = false;
            this.educationFrom = {};
          } else {
          }
        });
      }
    },
    // 教育背景查看详情
    educationDetails(row) {
      this.educationFrom = row;

      this.educationalVisible = true;
      this.educationDisabled = true;
    },
    /** 申请操作 */
    handleAdd() {
      console.log('1',this.$router.push({path:'/apply'}))
      // this.$router.push({path:'/apply/index'})
      this.$router.push({path:'/counselor/clrApply/apply'})
    //   this.department();
    //   this.open = true;
    //   this.form = this.userInfor.teacher
          
    // console.log("userInfor12313", this.form);
    //   this.title = "添加辅导员信息申请单";
    },
    /** 申请操作 */
    adjust() {
      // this.$router.push({path:'/apply/index'})
      this.$router.push({path:'/counselor/clrApply/adjust'})
    //   this.department();
    //   this.open = true;
    //   this.form = this.userInfor.teacher
          
    // console.log("userInfor12313", this.form);
    //   this.title = "添加辅导员信息申请单";
    },
    // 审批
    examine(row) {
      this.department(); 
      this.apprData = row
      if(row.parameter) {
        let data =JSON.parse(row.parameter)
      this.form = data.teacher
      this.clrEducationList = data.clrEducationList
      this.clrWorkHistoryList = data.clrWorkHistoryList
      this.sendUserIds = data.classList
      }   
      console.log("row",row);
      this.open = true;
    },
    //  拒绝审批
    async refuse() {
      let res = await appr({...this.apprData,apprStatus: '2'})
       if(res.code == 200) {
        this.$modal.msgSuccess("审批拒绝成功");
        this.open = false
        this.getList();
       }
    },
    /** 查询审批详情 */
    viewDetails(row) {
      const caiId = row.caiId || this.ids;
      getApprclrinfo(caiId).then(response => {
        this.form = response.data;
        this.clrApprRecordList = response.data.clrApprRecordList;
        this.beginOpen = true;
        this.title = "查看审批详情";
      });
    },
    /** 通过审批 */
    async submitForm() {
      console.log('111')
      let res = await appr({...this.apprData,apprStatus: '1'})
       if(res.code == 200) {
        this.$modal.msgSuccess("审批已通过");
        this.open = false
        this.getList();
       }
      
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const caiIds = row.caiId || this.ids;
      this.names = row.applyName || this.names;
      this.$modal
        .confirm('是否确认删除辅导员信息申请单编号为"' + this.names + '"的数据项？')
        .then(function() {
          return delApprclrinfo(caiIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 辅导员审批记录序号 */
    rowClrApprRecordIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 辅导员审批记录添加按钮操作 */
    handleAddClrApprRecord() {
      let obj = {};
      obj.confSeq = "";
      obj.apprTno = "";
      obj.apprName = "";
      obj.apprRole = "";
      obj.apprTime = "";
      obj.apprStatus = "";
      this.clrApprRecordList.push(obj);
    },
    /** 辅导员审批记录删除按钮操作 */
    handleDeleteClrApprRecord() {
      if (this.checkedClrApprRecord.length == 0) {
        this.$modal.msgError("请先选择要删除的辅导员审批记录数据");
      } else {
        const clrApprRecordList = this.clrApprRecordList;
        const checkedClrApprRecord = this.checkedClrApprRecord;
        this.clrApprRecordList = clrApprRecordList.filter(function(item) {
          return checkedClrApprRecord.indexOf(item.index) == -1;
        });
      }
    },
    /** 复选框选中数据 */
    handleClrApprRecordSelectionChange(selection) {
      this.checkedClrApprRecord = selection.map(item => item.index);
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "clr/apprclrinfo/export",
        {
          ...this.queryParams
        },
        `apprclrinfo_${new Date().getTime()}.xlsx`
      );
    }
  }
};
</script>
